<%--
  Created by IntelliJ IDEA.
  User: 33503
  Date: 2023/11/28
  Time: 20:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>新增学生</title>
  <!--引入jquery和bootstrap -->
  <script type="text/javascript" src="js/jquery-1.12.3.min.js"></script>
  <script type="text/javascript" src="js/bootstrap.min.js"></script>
  <style>
    .teacher-box {
      background-color: white;
      color: black;
      margin-left: 230px;
      margin-top: 30px;
      border-radius: 10px
    }

    .in-teacher-box {
      background: rgba(255, 255, 255, 0.6);
      box-shadow: 4px 4px 4px 4px #337ab7;
      padding: 10px;
      margin: 20px;
      width: 50%;
      font-size: 20px;
      border-radius: 15px;
      background-color: #66afe9;
    }

    .in-teacher-box input {
      font-size: 20px;
    }

    td {
      border: 10px solid #66afe9;
      text-align: center;
      padding: 15px 0;
      /*background-color: #66afe9;*/
      height: 40px;
      font-size: 20px;
      color: black;
    }

    input::-webkit-input-placeholder {
      font-size: 15px;
    }
  </style>
</head>
<body>
<%--菜单栏--%>
<jsp:include page="management_menu.jsp"></jsp:include>
<div align="center" class="teacher-box">
  <div style="font-size: 30px">新增学生</div>
  <a href="${pageContext.request.contextPath }/studentList"
     style="display: inline-block; background-color: #66afe9; font-size: 15px; float: left;color: black"><strong><</strong>返回上一级</a>
  <div align="center" class="in-teacher-box">
    <form action="${pageContext.request.contextPath }/addStudent" method="POST" id="addSForm">
      <table style="font-size: large">
        <tr>
          <td style="color: red; font-size: 20px" colspan="2">${wrongAddMsg}</td>
        </tr>
        <tr>
          <td>学&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</td>
          <td><input type="text" name="s_id" id="s_id" placeholder="请输入学生学号"></td>
        </tr>
        <tr>
          <td>学生姓名：</td>
          <td><input type="text" name="s_name" id="s_name" placeholder="请输入学生姓名"></td>
        </tr>
        <tr>
          <td>学&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;院：</td>
          <td><input type="text" name="college" id="college" placeholder="请输入学院"></td>
        </tr>
        <tr>
          <td>班&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;级：</td>
          <td><input type="text" name="s_class" id="s_class" placeholder="请输入班级"></td>
        </tr>
        <tr>
          <td>联系方式：</td>
          <td><input type="text" name="s_phone" id="s_phone" placeholder="请输入联系方式"></td>
        </tr>
        <tr>
          <td>密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码：</td>
          <td><input type="text" name="s_pwd" id="s_pwd" placeholder="请输入密码"></td>
        </tr>
      </table>
      <br>
      <input type="button" value="确认" onclick="adds()"
             style="height: 30px; width: 60px; background-color: #2e6da4; border-color: #2e6da4; border-radius: 5px; font-size: large; color: white; margin-right: 30px;"/>
      <input type="reset" value="重置"
             style="height: 30px; width: 60px; background-color: #2e6da4; border-color: #2e6da4; border-radius: 5px; font-size: large; color: white;  margin-left: 50px;"/>
    </form>
  </div>
</div>
<script>
  function myTrim(x) {
    return x.replace(/^\s+|\s+$/gm, '');
  }
  function adds() {
    //提交form表单前判断
    var s_id = myTrim($("#s_id").val());//消除空格
    var s_name = myTrim($("#s_name").val());
    var college = myTrim($("#college").val());//消除空格
    var s_class = myTrim($("#s_class").val());
    var s_phone = myTrim($("#s_phone").val());//消除空格
    var s_pwd = myTrim($("#s_pwd").val());
    if (s_id === "" || s_id == null) {
      alert("学号不能为空");
      return;
    } else if (s_name === "" || s_name == null) {
      alert("姓名不可为空");
      return;
    } else if (college === "" || college == null) {
      alert("学院不可为空");
      return;
    } else if (s_class === "" || s_class == null) {
      alert("班级不可为空");
      return;
    } else if (s_phone === "" || s_phone == null) {
      alert("联系方式不可为空");
      return;
    } else if (s_pwd === "" || s_pwd == null) {
      alert("密码不可为空");
      return;
    } else {
      //试题类型为单选题或多选题时，CD选项不可为空
      $("#addSForm").submit();
      alert('核验中***跳转成功即成功添加学生')
      return false;
    }
  }
</script>
</body>
</html>
